"use strict";

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

$(function () {
  $("#regBtn").click(function (e) {
    var s = e || window.event;s.preventDefault();var e = $(this).parents("form").find("p:eq(0)").find("input").val(),
        t = $(this).parents("form").find("p:eq(1)").find("input").val(),
        a = $(this).parents("form").find("p:eq(2)").find("input").val(),
        m = $(this).parents("form").find("p:eq(3)").find("input").val();e && t && a && m ? t != a ? $.message({ message: "密码不一致，请重新输入", type: "error" }) : /^\w{5,15}$/.test(e) ? /^\w{8,16}$/.test(t) ? $.post("http://kg.zhaodashen.cn/mt/web/user/registry.jsp", { uname: e, pwd: t, captcha: m }, function (e) {
      201 !== e.meta.state ? $.message({ message: e.meta.msg, type: "error" }) : ($.message({ message: e.meta.msg, type: "success" }), setTimeout(function () {
        location.href = "./login.html";
      }, 2e3), console.log(e.meta.msg));
    }, "json") : $.message({ message: "密码格式有误，请重新输入", type: "error" }) : $.message({ message: "请输入合法的用户名", type: "error" }) : $.message({ message: "账户名或密码不能为空", type: "error" });
  }), $(".smsReg .wof-button").click(function (e) {
    var s = e || window.event;s.preventDefault();var e = $(".mobile").val(),
        t = $(".smsReg").find(".code").val();/^1\d{10}$/.test(e) ? $.post("http://kg.zhaodashen.cn/mt/web/sms/registry.jsp", { mobile: e, code: t }, function (e) {
      201 === e.meta.state ? ($.message({ message: e.meta.msg, type: "success" }), setTimeout(function () {
        location.href = "./login.html";
      }, 2e3)) : $.message({ message: e.meta.msg, type: "error" });
    }, "json") : $.message({ message: "请输入正确的手机号", type: "error" });
  });var s = null,
      t = ($(".mobileBtn").click(function () {
    $("#captcha").text() || (s = captchaBigData("#captcha"));
  }), 5),
      a = null;$("#sendSmsBtn").click(_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
    var _this = this;

    var e;
    return regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            e = $(this).parents("form").find(".mobile").val();
            _context.t0 = a;

            if (_context.t0) {
              _context.next = 14;
              break;
            }

            if (!/^1\d{10}$/.test(e)) {
              _context.next = 13;
              break;
            }

            _context.next = 6;
            return s;

          case 6:
            if (!_context.sent.getValidate()) {
              _context.next = 10;
              break;
            }

            $(this).text(t + "s重新发送"), a = setInterval(function () {
              t--, $(_this).text(t + "s重新发送"), 0 === t && (clearInterval(a), a = null, t = 5, $(_this).text("重新获取"));
            }, 1e3), 5 === t && $.post("http://kg.zhaodashen.cn/mt/web/sms/send.jsp", { mobile: e }, function (e) {
              console.log(e), 201 === e.meta.state ? $.message({ message: "发送成功", type: "success" }) : $.message({ message: e.meta.msg, type: "error" });
            }, "json");
            _context.next = 11;
            break;

          case 10:
            $.message({ message: "请验证", type: "error" });

          case 11:
            _context.next = 14;
            break;

          case 13:
            $.message({ message: "请输入正确的手机号", type: "error" });

          case 14:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, this);
  })));
});